import path from 'path';
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite';
import VueDevTools from 'vite-plugin-vue-devtools';
import autoImport from 'unplugin-auto-import/vite'
import deletePack from './vite/plugins/delete-pack'
import zipPack from 'vite-plugin-zip-pack'
import { presetUno, presetAttributify } from 'unocss'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), autoImport({
    imports: [
      'vue',
      'vue-router',
      'pinia'
    ],
    dts: false,

  }), UnoCSS({
    presets: [
      presetUno(),
      presetAttributify(),
    ]
  }, VueDevTools()),
   zipPack({
     inDir: 'bigScreenFront',
    outDir: './',
     outFileName: 'bigScreenFront.zip',
    pathPrefix: ''
  }), deletePack({
    targets: [`./bigScreenFront`]  // 需要删除的文件或文件夹
  })
  ],
  build: {
    outDir: 'bigScreenFront',  // 自定义输出文件夹名称
  },
  resolve: {
    // https://cn.vitejs.dev/config/#resolve-alias
    alias: {
      // 设置路径
      '~': path.resolve(__dirname, './'),
      // 设置别名
      '@': path.resolve(__dirname, './src')
    },
    // https://cn.vitejs.dev/config/#resolve-extensions
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  },
  server: {
    port: 9007,
    host: true,
    open: true,
    proxy: {
      // https://cn.vitejs.dev/config/#server-proxy
      '/dev-api': {
        // target: 'http://47.104.0.169:8007',
        target: 'http://47.104.0.169:8008',
        // changeOrigin: true,
        rewrite: (p) => p.replace(/^\/dev-api/, '')
      }
    }
  },
  css: {
    postcss: './postcss.config.js', // 确保加载你的 postcss 配置
  },
})
